
uniform vec2		bumpScale1;
uniform vec2		bumpScroll1;
uniform vec2		bumpScale2;
uniform vec2		bumpScroll2;
uniform float		deformMagnitude;

varying vec2		alphaTexCoord;
varying vec4		bumpTexCoord;
varying float		deformScale;


void main (void){

	vec4		deformVec;
	float		d1, d2;

	// Position invariant
	gl_Position = ftransform();

	// Copy the alpha map texcoord
	alphaTexCoord = gl_MultiTexCoord0.st;

	// Scale and scroll the bump map texcoords
	bumpTexCoord.st = gl_MultiTexCoord0.st * bumpScale1 + bumpScroll1;
	bumpTexCoord.pq = gl_MultiTexCoord0.st * bumpScale2 + bumpScroll2;

	// Compute the deform scale
	deformVec.x = 1.0;
	deformVec.y = 0.0;
	deformVec.z = dot(gl_Vertex, gl_ModelViewMatrixTranspose[2]);
	deformVec.w = 1.0;

	d1 = dot(deformVec, gl_ProjectionMatrixTranspose[0]);
	d2 = dot(deformVec, gl_ProjectionMatrixTranspose[3]);

	deformScale = min(d1 * (1.0 / max(d2, 1.0)), 0.02) * deformMagnitude;
}
